<template>
	<view class="container">
		<view @click="toDetail(item)" v-for="(item, index) in list" :key="index" class="card">
			<view class="title flex-row"><view class="name">培训主题：{{ item.topic }}</view></view>
			<view class="item"><view>培训讲师：{{ item.teacher || '无' }}</view></view>
			<view class="item"><view>培训内容：{{ item.title }}</view></view>
		</view>
		<view class="nodata">没有更多了~</view>
	</view>
</template>

<script>
export default{
	data(){
		return {
			userid: uni.getStorageSync('userid'),
			page: 1,
			total: 1,
			list: []
		}
	},
	onShow(){
		this.getList();
	},
	methods: {
		toDetail(item){
			uni.setStorageSync('eduPreTrainDetail', item);
			uni.navigateTo({
				url: 'detail?type=create'
			});
		},
		// 获取列表
		getList(){
			let _this = this;
			uni.request({
				url: this.$API.eduPreTrainTemp,
				data: { userid: this.userid },
				header: this.$API.get_head(),
				success: (res)=>{
					_this.total = res.data.total;
					
					// 判断是第一页还是后续页
					let data = res.data.data;
					if(_this.page == 1){
						_this.list = data;
					}else{
						_this.list = _this.list.concat(data);
					}
				}
			})
		},
		// 分页加载
		getNextPageData(){
			this.page++;
			if(this.page < this.total){
				this.getList();
			}
		}
	}
}
</script>

<style scoped>
/*卡片*/
.card{
	background: #fff;
	margin: 20upx 20upx 0;
	border-radius: 16upx;
	padding: 14upx 20upx 8upx;
	border: 2upx solid #F6F6F6;
	box-shadow: 0 0 4upx #eee;
}
.card .title view{
	font-size: 28upx;
}
.card .title view.name{
	text-indent: 20upx;
	position: relative;
}
.card .title view.name::before{
	content: '';
	width: 10upx;
	height: 26upx;
	background: #5F96F2;
	border-radius: 4upx;
	position: absolute;
	top: 14upx;
	left: 0;
}
</style>
